using System.IO;

namespace Galplay {
  internal class ScriptBGS : GalScript {
    public int ID { get; set; }
    public string Filename { get; }

    public ScriptBGS(GalScene owner, XmlNode item) : base(owner, item, ScriptType.BGS) {
      ID = item.GetInt("ID");
      Filename = Kit.AutoAddExtension(item.InnerText, ".wav");
    }

    public override void Execute(GameScenePlayer player) {
      if (Kit.NotEmpty(Filename)) {
        GM.PlayBgs(GetBgsPath());
      } else {
        GM.PlayBgs(ID);
      }
    }

    private string GetBgsPath() {
      return Kit.AutoCombine(GM.Game.BgsPath, Filename);
    }
  }
}